import request from '@/utils/request'

// 获取角色
export const getRoles = function(obj) {
  return request.get('api/sys/role', { params: obj })
}

export const delRole = function(id) {
  return request.delete('api/sys/role/' + id)
}

// 添加角色
export const addRoles = function(data) {
  return request.post('api/sys/role/', data)
}

// 编辑角色
export const editRole = function(data) {
  return request.put('api/sys/role/' + data.id, data)
}

export function assignRole(id, roleIds) {
  return request.put('/sys/user/assignRoles', { id, roleIds })
}

export function getRoleDetail(id) {
  return request({
    url: `/sys/role/${id}`
  })
}

export function assignPerm(data) {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data
  })
}
